<?php

use yii\helpers\Html;
use yii\grid\GridView;
use yii\web\NotFoundHttpException;

//chỉ admin mới có quyền
if(Yii::$app->user->isGuest || Yii::$app->user->identity->acc_type!=0)
{
	throw new NotFoundHttpException('The requested page does not exist.');
}
else
{

	/* @var $this yii\web\View */
	/* @var $searchModel app\models\ProjectSearch */
	/* @var $dataProvider yii\data\ActiveDataProvider */

	$this->title = 'Các dự án captcha';
	//$this->params['breadcrumbs'][] = $this->title;
	?>
	<div class="project-index">

		<h1><?= Html::encode($this->title) ?></h1>
		<?php // echo $this->render('_search', ['model' => $searchModel]); ?>

		<p>
			<?= Html::a('Thêm dự án mới', ['create'], ['class' => 'btn btn-success']) ?>
		</p>

		<?= GridView::widget([
			'dataProvider' => $dataProvider,
			'filterModel' => $searchModel,
			'columns' => [
				['class' => 'yii\grid\SerialColumn'],
				'name',
				'rate',
				'description:ntext',
				//'guide:ntext',
				// 'link:ntext',
				['class' => 'yii\grid\ActionColumn'],
				['class' => 'yii\grid\ActionColumn',
					'template' => '{test-account}',
					'buttons' => [
						'test-account' => function ($url, $model) {
							return Html::a('DS tài khoản test', $url);
						},
					],
					'urlCreator' => function ($action, $model, $key, $index) {
						if ($action === 'test-account') {
							$url =  Yii::$app->UrlManager->createUrl(['/test-account/index/', 'pro_id'=>$model->id]);
							return $url;
						}
					}
				],
			],
		]); ?>

	</div>
<?php
}
?>